$OpenBSD: patch-tcl_tclCmdAH_c,v 1.3 2014/11/19 20:48:00 sthen Exp $
--- tcl/tclCmdAH.c.orig	Fri Feb 24 21:19:53 1995
+++ tcl/tclCmdAH.c	Wed Nov 19 20:36:11 2014
@@ -19,16 +19,13 @@
 static char rcsid[] = "$Header: /var/www/space/cvs/ports/net/icb/patches/patch-tcl_tclCmdAH_c,v 1.3 2014/11/19 20:48:00 sthen Exp $ SPRITE (Berkeley)";
 #endif /* not lint */
 
-#ifdef linux
-#include <unistd.h>
-#endif /* linux */
-
 #include <ctype.h>
 #include <errno.h>
 #include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <unistd.h>
 #include <sys/types.h>
 #include <sys/errno.h>
 #include <sys/file.h>
@@ -38,9 +35,17 @@ static char rcsid[] = "$Header: /home/agamotto/mark/pk
 #include <sys/wait.h>
 #include "tclInt.h"
 
+#if (defined(__unix__) || defined(unix)) && !defined(USG)
+#include <sys/param.h>
+#endif
+
 extern int errno;
+#if !(defined(BSD) && BSD >= 199306)
 extern long lseek();
+#endif
+#ifndef BSD4_4
 extern char *mktemp();
+#endif
 
 /*
  *----------------------------------------------------------------------
@@ -430,7 +435,7 @@ Tcl_ExecCmd(dummy, interp, argc, argv)
     int pid = -1;			/* -1 means child process doesn't
 					 * exist (yet).  Non-zero gives its
 					 * id (0 only in child). */
-    union wait status;
+    int status;
     char *cmdName, *execName;
 
     /*
@@ -501,8 +506,13 @@ Tcl_ExecCmd(dummy, interp, argc, argv)
     } else {
 	char tmp[sizeof(TMP_FILE_NAME) + 1];
 	strcpy(tmp, TMP_FILE_NAME);
+#ifdef BSD4_4
+	mkstemp(tmp);
+	stdIn[0] = mkstemp(tmp);
+#else
 	mktemp(tmp);
 	stdIn[0] = open(tmp, O_RDWR|O_CREAT, 0);
+#endif
 	if (stdIn[0] < 0) {
 	    sprintf(interp->result,
 		    "couldn't create input file for \"%.50s\" command: %.50s",
@@ -642,7 +652,7 @@ Tcl_ExecCmd(dummy, interp, argc, argv)
 	    sprintf(interp->result, "command terminated abnormally");
 	    result = TCL_ERROR;
 	}
-	result = status.w_retcode;
+	result = WEXITSTATUS(status);
     }
     if (stdIn[0] != -1) {
 	close(stdIn[0]);
